home *** CD-ROM | disk | FTP | other *** search
- #!/usr/bin/perl5
-
- # Apps.major.cgi
- # Silicon Graphics
-
- require "/usr/OnRamp/lib/OnRamp.pm";
- require "/usr/OnRamp/lib/java.pm";
-
- $myname = "Apps.major.cgi";
- $base_url = $ENV{'SERVER_URL'} . "/apps/major-info.cgi";
- $major_dir = "$document_root/apps/majordomo";
- $list_base = "/usr/freeware/lib/majordomo/lists";
- $title = "Majordomo Mailing Lists";
- $aliases = "/etc/aliases";
-
- opendir(DIR, "$major_dir");
- @lists = grep(!/^\.\.?$/, readdir(DIR));
- closedir(DIR);
- @lists = sort(@lists);
-
- &get_fields;
-
- $js = "
- $js_error_box
- which = \"none\";
- function runSubmit() {
- form = document.Form;
- if (which == \"sub\" || which == \"uns\") {
- if (form.email.value == \"\") {
- errorBox(form.email, \"Email address required.\");
- return (false);
- }
- if (form.s_list.value == \"\") {
- errorBox(form.s_list, \"List name required.\");
- return (false);
- }
- }
- if (which == \"loc\") {
- if (form.email.value == \"\") {
- errorBox(form.email, \"Email address required.\");
- return (false);
- }
- }
- if (which == \"search\") {
- if (form.srch.value == \"\") {
- errorBox(form.srch, \"Search string required.\");
- return (false);
- }
- }
- return (true);
- }
- function markSub() { which = \"sub\"; }
- function markUns() { which = \"uns\"; }
- function markLocate() { which = \"loc\"; }
- function markSearch() { which = \"search\"; }
- ";
-
- if ($fld{'Search'}) {
- if ($fld{'srch'} eq "") { $message .= "Empty search string."; }
- else {
- $srch = $fld{'srch'};
- @found = grep(/$srch/, @lists);
- if ($#found == -1) { $message .= "No mailing lists found in search."; }
- else { @found = sort(@found); }
- }
- } elsif ($fld{'locate'}) {
- $email = $fld{'email'};
- foreach $list (@lists) {
- $file = $list_base . "/" . $list;
- open(IN, "< $file");
- while(<IN>) {
- chop $_;
- if ($email eq $_) { push(@subsc, $list); }
- }
- close(IN);
- }
- } elsif ($fld{'subscribe'} || $fld{'unsub'}) {
- if ($fld{'subscribe'}) { $body = "subscribe"; }
- else { $body = "unsubscribe"; }
- $body .= " $fld{'s_list'}";
- $cmd = "echo \"$body\" | /usr/lib/sendmail -f$fld{'email'} majordomo@" . $ENV{'SERVER_NAME'};
- `$cmd > /dev/null 2>&1`;
-
- if ($fld{'subscribe'}) { $message .= "$fld{'email'} subscribed to $fld{'s_list'}.<br>"; }
- else { $message .= "$fld{'email'} removed from $fld{'s_list'}.<br>"; }
- }
-
- if (! -e "/usr/freeware/lib/majordomo-1.94.1/majordomo") {
- print "Content-type: text/html\n\n";
- print "<h2>Majordomo software not installed.</h2>"
- . "Majordomo is free software availale as an inst image "
- . "for your SGI server "
- . "(fw_majordomo). To configure and "
- . "administer majordomo through Internet Gateway, the "
- . "majordomo software must be installed from this image. ";
- exit(0);
- }
-
- &generic;
-
- sub generic {
- print "Content-type: text/html\n\n";
-
- &js_title_block("Majordomo", $js);
-
- print "<body bgcolor=#FFFFFF>\n";
-
- print "<i>$message</i>\n";
-
- open(IN, "< $aliases");
- while(<IN>) {
- if ($_ =~ /^owner-(.*):\s+(.*)/) {
- $owner{$1} = $2;
- }
- }
- close(IN);
-
- print "<table width=100%>",
- "<tr><th align=left><h2>$title</h2></th>\n",
- "<th align=right><a href=\"/newsplash.shtml\">",
- "<img height=55 width=57 border=0 src=/apps/home.gif></a>\n",
- " <a href=\"Apps.shtml\">",
- "<img height=55 width=57 border=0 src=/apps/back.gif></a>",
- "</tr></table><br><br>\n";
-
- print "<form name=Form method=post action=$myname onSubmit=\"return runSubmit()\">\n";
- print "<font size=5><b><tt>Subscription:</tt></b></font><br>\n";
- print "<center><table width=80%><tr align=left><th width=30%>Email address:<td width=20%>",
- &text("email", "", 15), "</td>\n"
- . "<td width=20%><input type=\"submit\" onClick=\"markSub()\" name=\"subscribe\" value=\" Subscribe \"></td></tr>";
- print "<tr><th align=left width=30%>Mailing list:<td width=20%>",
- &text("s_list", "", 15), "</td>\n"
- . "<td width=20%><input type=\"submit\" onClick=\"markUns()\" name=\"unsub\" value=\"Unsubscribe\"></td></tr>\n";
- print "<tr><th align=left colspan=2 width=50%>Locate mailing lists currently subscribed to:\n"
- . "<td width=20%><input type=\"submit\" onClick=\"markLocate()\" name=\"locate\" value=\" Search \"></td></tr>\n";
- print "</table></center>";
-
- if ($fld{'locate'}) {
- if ($#subsc == -1) { print "<i>$email is not subscribed to any "
- . "mailing lists on this server.</i><br>\n"; }
- else {
- print "<i>$email is currently subscribed to:</i><ul>\n";
- foreach (@subsc) {
- $url = $base_url . "?$_:$owner{$_}";
- print "<li><a href=$url>$_</a>\n";
- }
- print "</ul>\n";
- }
- print "<br>\n";
- }
-
- print "<hr><br>\n";
-
- print "<font size=5><b><tt>Mailing lists:</tt></b></font><br>\n";
-
- print "<center><table width=80%><tr><th align=left width=30%>Keyword search mailing list titles:<td width=20%>\n",
- &text("srch", "", 15), "</td><td width=20%>"
- . "<input type=\"submit\" onClick=\"markSearch()\" name=\"Search\" value=\" Search \">\n"
- . "</td></tr></table></center>\n";
- print "</form>";
-
- if ($#found >= 0) {
- print "<i>Found in search:</i>\n";
- print "<ul>\n";
- foreach (@found) {
- $url = $base_url . "?$_:$owner{$_}";
- print "<li><a href=$url>$_</a>\n";
- }
- print "</ul>\n";
- }
-
- print "<ul>\n";
-
- $third = ($#lists + 1)/3;
- if ($third =~ /([0-9]+)\./) { $third = $1; }
- $rem = ($#lists + 1) % 3;
- if ($rem == 0) { $a = $third; $b = $third; $c = $third; }
- elsif ($rem == 1) { $a = $third+1; $b = $third; $c = $third; }
- else { $a = $third+1; $b = $third+1; $c = $third; }
-
- print "<table><tr><td valign=top><ul>";
- for ($i=0; $i<$a; $i++) {
- $url = $base_url . "?$lists[$i]:$owner{$lists[$i]}";
- print "<li><a href=$url>$lists[$i]</a>\n";
- }
- print "</ul></td><td valign=top><ul>\n";
- for ($i=$a; $i<$a+$b; $i++) {
- $url = $base_url . "?$lists[$i]:$owner{$lists[$i]}";
- print "<li><a href=$url>$lists[$i]</a>\n";
- }
- print "</ul></td><td valign=top><ul>\n";
- for ($i=$a+$b; $i<=$#lists; $i++) {
- $url = $base_url . "?$lists[$i]:$owner{$lists[$i]}";
- print "<li><a href=$url>$lists[$i]</a>\n";
- }
- print "</ul></td></tr></table>\n";
-
- print "</body></html>\n";
- }
-